package org.bakerstreet.components;

import java.util.Map;

public class Component {
	
	public enum ComponentType{
		ComboBox,
		EditBox,
		CheckBox,
		TextArea
	}
	
	private String value;
	
	private static int lastId = 0;
	
	private int row;
	
	private int column;

	private String id;
	
	private boolean hasChanges = false;
	
	private boolean enabled = true;
	
	private Map<String,String> associatedDbItem;
	
	public Component(int row, int col, String value){
		this.id = this.newId();
		this.column = col;
		this.row = row;
		this.setValue(value);
	}
	
	
	public void setAssociatedDbItem(Map<String,String> assocItem){
		this.associatedDbItem = assocItem;
	}
	
	public Map<String, String> getAssociatedDbItem(){
		return this.associatedDbItem;
	}
	
	public Component(){
		super();
		this.id = this.newId();
	}
	
	private String newId() {
		return "CMP_"+lastId ++;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.setChanged(true);
		this.value = value;
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

	public int getColumn() {
		return column;
	}

	public void setColumn(int column) {
		this.column = column;
	}
	
	public String getId(){
		return this.id;
	}

	public boolean hasChanges() {
		return hasChanges;
	}

	public void setChanged(boolean hasChanges) {
		this.hasChanges = hasChanges;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.setChanged(true);
		this.enabled = enabled;
	}
	
	public void setId(String id){
		this.id = id;
	}
	
}
